// EJEditCtl.cpp : implementation file
//

#include "stdafx.h"
#include "EJWork.h"
#include "EJEditCtl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEJEditCtl

CEJEditCtl::CEJEditCtl()
{
}

CEJEditCtl::~CEJEditCtl()
{
}


BEGIN_MESSAGE_MAP(CEJEditCtl, CEdit)
	//{{AFX_MSG_MAP(CEJEditCtl)
	ON_WM_KEYUP()
	ON_WM_LBUTTONUP()
	ON_CONTROL_REFLECT(EN_CHANGE, OnInputChanged)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEJEditCtl message handlers

void CEJEditCtl::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	CEdit::OnKeyUp(nChar, nRepCnt, nFlags);

	switch(nChar)
	{
	case VK_LEFT:
	case VK_RIGHT:
	case VK_UP:
	case VK_DOWN:
	case VK_HOME:
	case VK_END:
	case VK_TAB:
		OnCaretChanged();
		break;
	default:
		break;
	}

}

void CEJEditCtl::OnLButtonUp(UINT nFlags, CPoint point) 
{
	CEdit::OnLButtonUp(nFlags, point);

	OnCaretChanged();
}

void CEJEditCtl::OnCaretChanged()
{
	int w;
	CPoint pt;
	WORD row;

	pt = GetCaretPos();

	w = CEdit::CharFromPos(pt);
	row = HIWORD(w);

//	TRACE("ROW = %d\r\n",row);
}

void CEJEditCtl::OnInputChanged() 
{
	CEJEditView* ev = (CEJEditView *)GetOwner();
	ev->OnInputChanged();
}


